package com.roc.steelend.controller;

import com.roc.steelend.controller.vo.returnformat.ReturnMsgForTable;
import com.roc.steelend.service.CompanyMoneyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@CrossOrigin
@Api(tags = "公司总账务功能接口")
public class CompanyMoneyController {

    @Autowired
    private CompanyMoneyService companyMoneyService;

    @GetMapping("/v1/companymoney/all")
    @ApiOperation(value = "查询公司的账务")
    public List<HashMap<String,Object>> findAllCompanyMoneyDetail(){
        return companyMoneyService.findAllCompanyMoneyDetail();
    }


    /**
     * 展示某付款方式的账务细节
     */
    @GetMapping("/v1/companymoney/detail")
    public ReturnMsgForTable findCompanymoneyDetail(@RequestParam Integer allCompanyMoneyId,
                                                    @RequestParam Integer currentPage,
                                                    @RequestParam Integer pageSize){

        ReturnMsgForTable returnMsgForTable = new ReturnMsgForTable();
        List<HashMap<String, Object>> companymoneyDetail = companyMoneyService.findCompanymoneyDetail(allCompanyMoneyId, currentPage, pageSize);
        Integer companymoneyDetailCount = companyMoneyService.findCompanymoneyDetailCount(allCompanyMoneyId);
        returnMsgForTable.setTotal(companymoneyDetailCount);
        returnMsgForTable.setCurrenPage(currentPage);
        returnMsgForTable.setObjectList(companymoneyDetail);
        return  returnMsgForTable;

    }
}
